/*
 * To change this t

@Override
public int getWidth(ImageObserver observer) {
throw new UnsupportedOperationException("Not supported yet.");
}

@Override
public int getHeight(ImageObserver observer) {
throw new UnsupportedOperationException("Not supported yet.");
}

@Override
public ImageProducer getSource() {
throw new UnsupportedOperationException("Not supported yet.");
}

@Override
public Graphics getGraphics() {
throw new UnsupportedOperationException("Not supported yet.");
}

@Override
public Object getProperty(String name, ImageObserver observer) {
throw new UnsupportedOperationException("Not supported yet.");
}
}mplate, choose Tools | Templates
 * and open the template in the editor.
 */

/*
 * Principal.java
 *
 * Created on 21/12/2009, 12:17:28 PM
 */
package org.constant.gui;

import java.awt.AWTException;
import java.awt.Component;
import java.awt.Image;
import java.awt.MenuItem;
import java.awt.PopupMenu;
import java.awt.SystemTray;
import java.awt.Toolkit;
import java.awt.TrayIcon;
import java.awt.event.ActionEvent;
import java.awt.event.ActionListener;
import java.io.File;
import java.util.LinkedList;
import java.util.List;
import javax.swing.ImageIcon;
import javax.swing.JCheckBox;
import javax.swing.JOptionPane;
import javax.swing.JPanel;
import javax.swing.UIManager;
import javax.swing.UIManager.LookAndFeelInfo;
import javax.swing.tree.DefaultTreeModel;
import javax.swing.tree.TreeSelectionModel;
import org.constant.gui.acciones.AccionArbol;
import org.constant.gui.util.ArbolManager;
import org.constant.tareas.TareaSegundoPlano;
import org.constant.util.ArchivosUtil;
import org.constant.util.InformacionArchivo;

/**
 *
 * @author gsierra
 */
public class Principal extends javax.swing.JFrame {

    public static final int VISTA_ARCHIVOS = 0;
    public static final int VISTA_ICONOS = 1;
    private static int tipoVista;
    private static ArchivosUtil archivosUtil;
    private List<File> raices;
    private DefaultTreeModel modelo;
    private NodoArbol raiz;
    private ArbolManager arbolManager;
    private static PanelDirectorio pDirectorio;
    private static PanelDirectorioIconos pDirectorioIconos;
    private static TrayIcon trayIcon;
    private TareaSegundoPlano tarea;

    static {
        pDirectorio = new PanelDirectorio();
        pDirectorioIconos = new PanelDirectorioIconos();
        pDirectorio.setVisible(false);
        pDirectorioIconos.setVisible(false);

        if (SystemTray.isSupported()) {
            SystemTray tray = SystemTray.getSystemTray();

            ImageIcon im = new ImageIcon(Principal.class.getResource("icon.png"));
            Image image = Toolkit.getDefaultToolkit().getImage(Principal.class.getResource("icon.png"));
            ActionListener exitListener = new ActionListener() {

                public void actionPerformed(ActionEvent e) {
                    System.out.println("Exiting...");
                    System.exit(0);
                }
            };
            PopupMenu popup = new PopupMenu();
            MenuItem defaultItem = new MenuItem("Salir");
            defaultItem.addActionListener(exitListener);
            popup.add(defaultItem);
            defaultItem = new MenuItem("Salir");
            defaultItem.addActionListener(exitListener);
            popup.add(defaultItem);
            trayIcon = new TrayIcon(im.getImage(), "Tray Icon", popup);
            ActionListener actionListener = new ActionListener() {

                public void actionPerformed(ActionEvent e) {
                    trayIcon.displayMessage("Action Event",
                            "An Action Event Has Been Peformed!",
                            TrayIcon.MessageType.INFO);
                }
            };
            trayIcon.setImageAutoSize(true);
            trayIcon.addActionListener(actionListener);
            try {
                tray.add(trayIcon);
            } catch (AWTException ex) {
                ex.printStackTrace();
            }
        }
    }

    /** Creates new form Principal */
    public Principal() {
        raiz = new NodoArbol(null);
        modelo = new DefaultTreeModel(raiz);
        archivosUtil = new ArchivosUtil();
        initComponents();
        cargaDevices();
        tArbol.getSelectionModel().setSelectionMode(TreeSelectionModel.SINGLE_TREE_SELECTION);
        tArbol.addTreeSelectionListener(new AccionArbol());
        try {
            for (LookAndFeelInfo info : UIManager.getInstalledLookAndFeels()) {
                if ("Nimbus".equals(info.getName())) {
                    UIManager.setLookAndFeel(info.getClassName());
                    break;
                }
            }
        } catch (Exception e) {
            // If Nimbus is not available, you can set the GUI to another look and feel.
        }

        this.setVisible(true);

    }

    private void cargaDevices() {
        this.raices = archivosUtil.getRaices();
        for (File archivo : this.raices) {
            JCheckBox check = new JCheckBox(archivo.getAbsolutePath());
            pDevices.add(check);
        }
        if (raices.size() > 0) {
            bEscanear.setEnabled(true);
        }
    }

    public void escaneaDispositivos() {
        List<String> dispositivosExaminar = new LinkedList<String>();
        Component[] cmp = pDevices.getComponents();
        for (int i = 0; i < cmp.length; i++) {
            Component component = cmp[i];
            if (component instanceof JCheckBox) {
                JCheckBox cb = (JCheckBox) component;
                if (cb.isSelected()) {
                    dispositivosExaminar.add(cb.getText());
                }
            }
        }
        if (dispositivosExaminar.size() == 0) {
            JOptionPane.showMessageDialog(this, "Debe seleccionar al menos una unidad", "Error en Dispositivos", JOptionPane.ERROR_MESSAGE);
        } else {
            cargaArbol(dispositivosExaminar);
        }
    }

    /** This method is called from within the constructor to
     * initialize the form.
     * WARNING: Do NOT modify this code. The content of this method is
     * always regenerated by the Form Editor.
     */
    @SuppressWarnings("unchecked")
    // <editor-fold defaultstate="collapsed" desc="Generated Code">//GEN-BEGIN:initComponents
    private void initComponents() {

        pDevices = new javax.swing.JPanel();
        bEscanear = new javax.swing.JButton();
        spContenido = new javax.swing.JSplitPane();
        pArbol = new javax.swing.JPanel();
        spArbol = new javax.swing.JScrollPane();
        tArbol = new javax.swing.JTree();
        pContenido = new javax.swing.JPanel();
        jLabel9 = new javax.swing.JLabel();
        cbVista = new javax.swing.JComboBox();
        pInterno = new javax.swing.JPanel();
        pInformacion = new javax.swing.JPanel();
        jLabel1 = new javax.swing.JLabel();
        jLabel4 = new javax.swing.JLabel();
        tfNombre = new javax.swing.JTextField();
        tfTamanho = new javax.swing.JTextField();
        jLabel5 = new javax.swing.JLabel();
        jLabel6 = new javax.swing.JLabel();
        tfDirectorio = new javax.swing.JTextField();
        tfPadre = new javax.swing.JTextField();
        jLabel8 = new javax.swing.JLabel();
        tfModificacion = new javax.swing.JTextField();
        jPanel2 = new javax.swing.JPanel();
        cbOculto = new javax.swing.JCheckBox();
        cbLeible = new javax.swing.JCheckBox();
        cbEjecutable = new javax.swing.JCheckBox();
        cbEscribible = new javax.swing.JCheckBox();
        pInformacionDisco = new javax.swing.JPanel();
        jLabel2 = new javax.swing.JLabel();
        jLabel3 = new javax.swing.JLabel();
        jLabel7 = new javax.swing.JLabel();
        tfTamanoDD = new javax.swing.JTextField();
        tfTamanoUsado = new javax.swing.JTextField();
        tfTamanoLibre = new javax.swing.JTextField();
        pProgreso = new javax.swing.JProgressBar();

        setDefaultCloseOperation(javax.swing.WindowConstants.EXIT_ON_CLOSE);
        setTitle("Examinador de archivos");
        setIconImage(new javax.swing.ImageIcon(Principal.class.getResource("icon.png")).getImage());

        pDevices.setBorder(javax.swing.BorderFactory.createTitledBorder("Dispositivos"));

        bEscanear.setText("Escanear");
        bEscanear.setEnabled(false);
        bEscanear.addActionListener(new java.awt.event.ActionListener() {
            public void actionPerformed(java.awt.event.ActionEvent evt) {
                bEscanearActionPerformed(evt);
            }
        });

        tArbol = new javax.swing.JTree(modelo);
        tArbol.setEnabled(false);
        spArbol.setViewportView(tArbol);

        org.jdesktop.layout.GroupLayout pArbolLayout = new org.jdesktop.layout.GroupLayout(pArbol);
        pArbol.setLayout(pArbolLayout);
        pArbolLayout.setHorizontalGroup(
            pArbolLayout.createParallelGroup(org.jdesktop.layout.GroupLayout.LEADING)
            .add(spArbol, org.jdesktop.layout.GroupLayout.DEFAULT_SIZE, 145, Short.MAX_VALUE)
        );
        pArbolLayout.setVerticalGroup(
            pArbolLayout.createParallelGroup(org.jdesktop.layout.GroupLayout.LEADING)
            .add(spArbol, org.jdesktop.layout.GroupLayout.DEFAULT_SIZE, 402, Short.MAX_VALUE)
        );

        spContenido.setLeftComponent(pArbol);

        jLabel9.setText("Vista");

        cbVista.setModel(new javax.swing.DefaultComboBoxModel(new String[] { "Archivos", "Iconos" }));
        cbVista.addActionListener(new java.awt.event.ActionListener() {
            public void actionPerformed(java.awt.event.ActionEvent evt) {
                cbVistaActionPerformed(evt);
            }
        });

        org.jdesktop.layout.GroupLayout pContenidoLayout = new org.jdesktop.layout.GroupLayout(pContenido);
        pContenido.setLayout(pContenidoLayout);
        pContenidoLayout.setHorizontalGroup(
            pContenidoLayout.createParallelGroup(org.jdesktop.layout.GroupLayout.LEADING)
            .add(pContenidoLayout.createSequentialGroup()
                .addContainerGap(259, Short.MAX_VALUE)
                .add(jLabel9)
                .addPreferredGap(org.jdesktop.layout.LayoutStyle.RELATED)
                .add(cbVista, org.jdesktop.layout.GroupLayout.PREFERRED_SIZE, 116, org.jdesktop.layout.GroupLayout.PREFERRED_SIZE))
            .add(org.jdesktop.layout.GroupLayout.TRAILING, pInterno, org.jdesktop.layout.GroupLayout.DEFAULT_SIZE, 402, Short.MAX_VALUE)
        );
        pContenidoLayout.setVerticalGroup(
            pContenidoLayout.createParallelGroup(org.jdesktop.layout.GroupLayout.LEADING)
            .add(pContenidoLayout.createSequentialGroup()
                .add(pContenidoLayout.createParallelGroup(org.jdesktop.layout.GroupLayout.BASELINE)
                    .add(cbVista, org.jdesktop.layout.GroupLayout.PREFERRED_SIZE, org.jdesktop.layout.GroupLayout.DEFAULT_SIZE, org.jdesktop.layout.GroupLayout.PREFERRED_SIZE)
                    .add(jLabel9))
                .addPreferredGap(org.jdesktop.layout.LayoutStyle.RELATED)
                .add(pInterno, org.jdesktop.layout.GroupLayout.DEFAULT_SIZE, 374, Short.MAX_VALUE))
        );

        spContenido.setRightComponent(pContenido);

        pInformacion.setBorder(javax.swing.BorderFactory.createTitledBorder("Información"));

        jLabel1.setText("Nombre");

        jLabel4.setText("Tamaño");

        tfNombre.setEditable(false);

        tfTamanho.setEditable(false);

        jLabel5.setText("Directorio");

        jLabel6.setText("Padre");

        tfDirectorio.setEditable(false);

        tfPadre.setEditable(false);

        jLabel8.setText("Última Modificación");

        tfModificacion.setEditable(false);

        jPanel2.setBorder(javax.swing.BorderFactory.createTitledBorder("Propiedades"));

        cbOculto.setText("Oculto");

        cbLeible.setText("Leíble");

        cbEjecutable.setText("Ejecutable");

        cbEscribible.setText("Escribible");
        cbEscribible.addActionListener(new java.awt.event.ActionListener() {
            public void actionPerformed(java.awt.event.ActionEvent evt) {
                cbEscribibleActionPerformed(evt);
            }
        });

        org.jdesktop.layout.GroupLayout jPanel2Layout = new org.jdesktop.layout.GroupLayout(jPanel2);
        jPanel2.setLayout(jPanel2Layout);
        jPanel2Layout.setHorizontalGroup(
            jPanel2Layout.createParallelGroup(org.jdesktop.layout.GroupLayout.LEADING)
            .add(jPanel2Layout.createSequentialGroup()
                .addContainerGap()
                .add(jPanel2Layout.createParallelGroup(org.jdesktop.layout.GroupLayout.LEADING)
                    .add(cbLeible)
                    .add(cbEjecutable)
                    .add(cbEscribible)
                    .add(cbOculto))
                .addContainerGap(43, Short.MAX_VALUE))
        );
        jPanel2Layout.setVerticalGroup(
            jPanel2Layout.createParallelGroup(org.jdesktop.layout.GroupLayout.LEADING)
            .add(jPanel2Layout.createSequentialGroup()
                .add(cbOculto)
                .addPreferredGap(org.jdesktop.layout.LayoutStyle.UNRELATED)
                .add(cbLeible)
                .addPreferredGap(org.jdesktop.layout.LayoutStyle.RELATED)
                .add(cbEjecutable)
                .addPreferredGap(org.jdesktop.layout.LayoutStyle.RELATED)
                .add(cbEscribible))
        );

        org.jdesktop.layout.GroupLayout pInformacionLayout = new org.jdesktop.layout.GroupLayout(pInformacion);
        pInformacion.setLayout(pInformacionLayout);
        pInformacionLayout.setHorizontalGroup(
            pInformacionLayout.createParallelGroup(org.jdesktop.layout.GroupLayout.LEADING)
            .add(pInformacionLayout.createSequentialGroup()
                .addContainerGap()
                .add(pInformacionLayout.createParallelGroup(org.jdesktop.layout.GroupLayout.LEADING)
                    .add(org.jdesktop.layout.GroupLayout.TRAILING, pInformacionLayout.createSequentialGroup()
                        .add(pInformacionLayout.createParallelGroup(org.jdesktop.layout.GroupLayout.LEADING)
                            .add(org.jdesktop.layout.GroupLayout.TRAILING, pInformacionLayout.createSequentialGroup()
                                .add(jLabel1)
                                .addPreferredGap(org.jdesktop.layout.LayoutStyle.UNRELATED))
                            .add(pInformacionLayout.createSequentialGroup()
                                .add(jLabel6)
                                .add(19, 19, 19)))
                        .add(pInformacionLayout.createParallelGroup(org.jdesktop.layout.GroupLayout.LEADING)
                            .add(tfPadre, org.jdesktop.layout.GroupLayout.DEFAULT_SIZE, 313, Short.MAX_VALUE)
                            .add(tfNombre, org.jdesktop.layout.GroupLayout.DEFAULT_SIZE, 313, Short.MAX_VALUE)))
                    .add(pInformacionLayout.createSequentialGroup()
                        .add(pInformacionLayout.createParallelGroup(org.jdesktop.layout.GroupLayout.LEADING)
                            .add(jLabel5)
                            .add(jLabel4))
                        .add(1, 1, 1)
                        .add(pInformacionLayout.createParallelGroup(org.jdesktop.layout.GroupLayout.LEADING)
                            .add(pInformacionLayout.createSequentialGroup()
                                .add(tfTamanho, org.jdesktop.layout.GroupLayout.PREFERRED_SIZE, 60, org.jdesktop.layout.GroupLayout.PREFERRED_SIZE)
                                .addPreferredGap(org.jdesktop.layout.LayoutStyle.RELATED)
                                .add(jLabel8)
                                .addPreferredGap(org.jdesktop.layout.LayoutStyle.RELATED)
                                .add(tfModificacion, org.jdesktop.layout.GroupLayout.DEFAULT_SIZE, 155, Short.MAX_VALUE))
                            .add(tfDirectorio, org.jdesktop.layout.GroupLayout.DEFAULT_SIZE, 313, Short.MAX_VALUE))))
                .add(18, 18, 18)
                .add(jPanel2, org.jdesktop.layout.GroupLayout.PREFERRED_SIZE, org.jdesktop.layout.GroupLayout.DEFAULT_SIZE, org.jdesktop.layout.GroupLayout.PREFERRED_SIZE)
                .addContainerGap())
        );
        pInformacionLayout.setVerticalGroup(
            pInformacionLayout.createParallelGroup(org.jdesktop.layout.GroupLayout.LEADING)
            .add(pInformacionLayout.createSequentialGroup()
                .add(pInformacionLayout.createParallelGroup(org.jdesktop.layout.GroupLayout.BASELINE)
                    .add(jLabel1)
                    .add(tfNombre, org.jdesktop.layout.GroupLayout.PREFERRED_SIZE, org.jdesktop.layout.GroupLayout.DEFAULT_SIZE, org.jdesktop.layout.GroupLayout.PREFERRED_SIZE))
                .addPreferredGap(org.jdesktop.layout.LayoutStyle.RELATED)
                .add(pInformacionLayout.createParallelGroup(org.jdesktop.layout.GroupLayout.BASELINE)
                    .add(jLabel6)
                    .add(tfPadre, org.jdesktop.layout.GroupLayout.PREFERRED_SIZE, org.jdesktop.layout.GroupLayout.DEFAULT_SIZE, org.jdesktop.layout.GroupLayout.PREFERRED_SIZE))
                .addPreferredGap(org.jdesktop.layout.LayoutStyle.RELATED)
                .add(pInformacionLayout.createParallelGroup(org.jdesktop.layout.GroupLayout.BASELINE)
                    .add(jLabel5)
                    .add(tfDirectorio, org.jdesktop.layout.GroupLayout.PREFERRED_SIZE, org.jdesktop.layout.GroupLayout.DEFAULT_SIZE, org.jdesktop.layout.GroupLayout.PREFERRED_SIZE))
                .addPreferredGap(org.jdesktop.layout.LayoutStyle.RELATED)
                .add(pInformacionLayout.createParallelGroup(org.jdesktop.layout.GroupLayout.BASELINE)
                    .add(jLabel4)
                    .add(tfTamanho, org.jdesktop.layout.GroupLayout.PREFERRED_SIZE, org.jdesktop.layout.GroupLayout.DEFAULT_SIZE, org.jdesktop.layout.GroupLayout.PREFERRED_SIZE)
                    .add(jLabel8)
                    .add(tfModificacion, org.jdesktop.layout.GroupLayout.PREFERRED_SIZE, org.jdesktop.layout.GroupLayout.DEFAULT_SIZE, org.jdesktop.layout.GroupLayout.PREFERRED_SIZE)))
            .add(jPanel2, org.jdesktop.layout.GroupLayout.PREFERRED_SIZE, org.jdesktop.layout.GroupLayout.DEFAULT_SIZE, org.jdesktop.layout.GroupLayout.PREFERRED_SIZE)
        );

        pInformacionDisco.setBorder(javax.swing.BorderFactory.createTitledBorder("Información del disco"));

        jLabel2.setText("Tamaño");

        jLabel3.setText("Espacio Usado");

        jLabel7.setText("Espacio Libre");

        tfTamanoDD.setEditable(false);

        tfTamanoUsado.setEditable(false);

        tfTamanoLibre.setEditable(false);

        org.jdesktop.layout.GroupLayout pInformacionDiscoLayout = new org.jdesktop.layout.GroupLayout(pInformacionDisco);
        pInformacionDisco.setLayout(pInformacionDiscoLayout);
        pInformacionDiscoLayout.setHorizontalGroup(
            pInformacionDiscoLayout.createParallelGroup(org.jdesktop.layout.GroupLayout.LEADING)
            .add(pInformacionDiscoLayout.createSequentialGroup()
                .addContainerGap()
                .add(pInformacionDiscoLayout.createParallelGroup(org.jdesktop.layout.GroupLayout.LEADING)
                    .add(pInformacionDiscoLayout.createSequentialGroup()
                        .add(jLabel7)
                        .addPreferredGap(org.jdesktop.layout.LayoutStyle.UNRELATED)
                        .add(tfTamanoLibre, org.jdesktop.layout.GroupLayout.DEFAULT_SIZE, 81, Short.MAX_VALUE))
                    .add(pInformacionDiscoLayout.createSequentialGroup()
                        .add(pInformacionDiscoLayout.createParallelGroup(org.jdesktop.layout.GroupLayout.LEADING)
                            .add(jLabel3)
                            .add(jLabel2))
                        .addPreferredGap(org.jdesktop.layout.LayoutStyle.RELATED)
                        .add(pInformacionDiscoLayout.createParallelGroup(org.jdesktop.layout.GroupLayout.LEADING)
                            .add(tfTamanoDD, org.jdesktop.layout.GroupLayout.PREFERRED_SIZE, 80, org.jdesktop.layout.GroupLayout.PREFERRED_SIZE)
                            .add(tfTamanoUsado, org.jdesktop.layout.GroupLayout.DEFAULT_SIZE, 80, Short.MAX_VALUE))))
                .add(375, 375, 375))
        );
        pInformacionDiscoLayout.setVerticalGroup(
            pInformacionDiscoLayout.createParallelGroup(org.jdesktop.layout.GroupLayout.LEADING)
            .add(pInformacionDiscoLayout.createSequentialGroup()
                .add(pInformacionDiscoLayout.createParallelGroup(org.jdesktop.layout.GroupLayout.BASELINE)
                    .add(jLabel2)
                    .add(tfTamanoDD, org.jdesktop.layout.GroupLayout.PREFERRED_SIZE, org.jdesktop.layout.GroupLayout.DEFAULT_SIZE, org.jdesktop.layout.GroupLayout.PREFERRED_SIZE))
                .addPreferredGap(org.jdesktop.layout.LayoutStyle.RELATED)
                .add(pInformacionDiscoLayout.createParallelGroup(org.jdesktop.layout.GroupLayout.BASELINE)
                    .add(jLabel3)
                    .add(tfTamanoUsado, org.jdesktop.layout.GroupLayout.PREFERRED_SIZE, org.jdesktop.layout.GroupLayout.DEFAULT_SIZE, org.jdesktop.layout.GroupLayout.PREFERRED_SIZE))
                .addPreferredGap(org.jdesktop.layout.LayoutStyle.RELATED, org.jdesktop.layout.GroupLayout.DEFAULT_SIZE, Short.MAX_VALUE)
                .add(pInformacionDiscoLayout.createParallelGroup(org.jdesktop.layout.GroupLayout.BASELINE)
                    .add(jLabel7)
                    .add(tfTamanoLibre, org.jdesktop.layout.GroupLayout.PREFERRED_SIZE, org.jdesktop.layout.GroupLayout.DEFAULT_SIZE, org.jdesktop.layout.GroupLayout.PREFERRED_SIZE)))
        );

        pProgreso.setEnabled(false);

        org.jdesktop.layout.GroupLayout layout = new org.jdesktop.layout.GroupLayout(getContentPane());
        getContentPane().setLayout(layout);
        layout.setHorizontalGroup(
            layout.createParallelGroup(org.jdesktop.layout.GroupLayout.LEADING)
            .add(org.jdesktop.layout.GroupLayout.TRAILING, layout.createSequentialGroup()
                .add(layout.createParallelGroup(org.jdesktop.layout.GroupLayout.TRAILING)
                    .add(pDevices, org.jdesktop.layout.GroupLayout.DEFAULT_SIZE, 564, Short.MAX_VALUE)
                    .add(org.jdesktop.layout.GroupLayout.LEADING, layout.createSequentialGroup()
                        .addContainerGap()
                        .add(spContenido))
                    .add(org.jdesktop.layout.GroupLayout.LEADING, layout.createSequentialGroup()
                        .add(243, 243, 243)
                        .add(bEscanear))
                    .add(org.jdesktop.layout.GroupLayout.LEADING, layout.createSequentialGroup()
                        .addContainerGap()
                        .add(pInformacionDisco, org.jdesktop.layout.GroupLayout.DEFAULT_SIZE, org.jdesktop.layout.GroupLayout.DEFAULT_SIZE, Short.MAX_VALUE))
                    .add(org.jdesktop.layout.GroupLayout.LEADING, layout.createSequentialGroup()
                        .addContainerGap()
                        .add(pInformacion, org.jdesktop.layout.GroupLayout.DEFAULT_SIZE, org.jdesktop.layout.GroupLayout.DEFAULT_SIZE, Short.MAX_VALUE))
                    .add(org.jdesktop.layout.GroupLayout.LEADING, layout.createSequentialGroup()
                        .add(10, 10, 10)
                        .add(pProgreso, org.jdesktop.layout.GroupLayout.DEFAULT_SIZE, 554, Short.MAX_VALUE)))
                .addContainerGap())
        );
        layout.setVerticalGroup(
            layout.createParallelGroup(org.jdesktop.layout.GroupLayout.LEADING)
            .add(layout.createSequentialGroup()
                .add(pDevices, org.jdesktop.layout.GroupLayout.PREFERRED_SIZE, 69, org.jdesktop.layout.GroupLayout.PREFERRED_SIZE)
                .addPreferredGap(org.jdesktop.layout.LayoutStyle.RELATED)
                .add(bEscanear, org.jdesktop.layout.GroupLayout.PREFERRED_SIZE, 23, org.jdesktop.layout.GroupLayout.PREFERRED_SIZE)
                .addPreferredGap(org.jdesktop.layout.LayoutStyle.RELATED)
                .add(pProgreso, org.jdesktop.layout.GroupLayout.PREFERRED_SIZE, org.jdesktop.layout.GroupLayout.DEFAULT_SIZE, org.jdesktop.layout.GroupLayout.PREFERRED_SIZE)
                .addPreferredGap(org.jdesktop.layout.LayoutStyle.UNRELATED)
                .add(spContenido, org.jdesktop.layout.GroupLayout.PREFERRED_SIZE, 404, org.jdesktop.layout.GroupLayout.PREFERRED_SIZE)
                .addPreferredGap(org.jdesktop.layout.LayoutStyle.RELATED)
                .add(pInformacion, org.jdesktop.layout.GroupLayout.PREFERRED_SIZE, org.jdesktop.layout.GroupLayout.DEFAULT_SIZE, org.jdesktop.layout.GroupLayout.PREFERRED_SIZE)
                .addPreferredGap(org.jdesktop.layout.LayoutStyle.RELATED)
                .add(pInformacionDisco, org.jdesktop.layout.GroupLayout.PREFERRED_SIZE, org.jdesktop.layout.GroupLayout.DEFAULT_SIZE, org.jdesktop.layout.GroupLayout.PREFERRED_SIZE)
                .addContainerGap(112, Short.MAX_VALUE))
        );

        pack();
    }// </editor-fold>//GEN-END:initComponents

    private void bEscanearActionPerformed(java.awt.event.ActionEvent evt) {//GEN-FIRST:event_bEscanearActionPerformed
        if (tarea == null) {
            tarea = new TareaSegundoPlano(this);
        }
        tarea.execute();
    }//GEN-LAST:event_bEscanearActionPerformed

    public void reestablece(Boolean estado) {
        bEscanear.setEnabled(estado);
        pProgreso.setIndeterminate(!estado);
    }
    private void cbEscribibleActionPerformed(java.awt.event.ActionEvent evt) {//GEN-FIRST:event_cbEscribibleActionPerformed
        // TODO add your handling code here:
    }//GEN-LAST:event_cbEscribibleActionPerformed

    private void cbVistaActionPerformed(java.awt.event.ActionEvent evt) {//GEN-FIRST:event_cbVistaActionPerformed
        Principal.tipoVista = cbVista.getSelectedIndex();
    }//GEN-LAST:event_cbVistaActionPerformed
    // Variables declaration - do not modify//GEN-BEGIN:variables
    private javax.swing.JButton bEscanear;
    private static javax.swing.JCheckBox cbEjecutable;
    private static javax.swing.JCheckBox cbEscribible;
    private static javax.swing.JCheckBox cbLeible;
    private static javax.swing.JCheckBox cbOculto;
    private static javax.swing.JComboBox cbVista;
    private javax.swing.JLabel jLabel1;
    private javax.swing.JLabel jLabel2;
    private javax.swing.JLabel jLabel3;
    private javax.swing.JLabel jLabel4;
    private javax.swing.JLabel jLabel5;
    private javax.swing.JLabel jLabel6;
    private javax.swing.JLabel jLabel7;
    private javax.swing.JLabel jLabel8;
    private static javax.swing.JLabel jLabel9;
    private javax.swing.JPanel jPanel2;
    private javax.swing.JPanel pArbol;
    private static javax.swing.JPanel pContenido;
    private javax.swing.JPanel pDevices;
    private javax.swing.JPanel pInformacion;
    private javax.swing.JPanel pInformacionDisco;
    private static javax.swing.JPanel pInterno;
    private javax.swing.JProgressBar pProgreso;
    private javax.swing.JScrollPane spArbol;
    private static javax.swing.JSplitPane spContenido;
    private javax.swing.JTree tArbol;
    private static javax.swing.JTextField tfDirectorio;
    private static javax.swing.JTextField tfModificacion;
    private static javax.swing.JTextField tfNombre;
    private static javax.swing.JTextField tfPadre;
    private static javax.swing.JTextField tfTamanho;
    private static javax.swing.JTextField tfTamanoDD;
    private static javax.swing.JTextField tfTamanoLibre;
    private static javax.swing.JTextField tfTamanoUsado;
    // End of variables declaration//GEN-END:variables

    private void cargaArbol(List<String> dispositivosExaminar) {
        arbolManager = new ArbolManager(archivosUtil, tArbol, dispositivosExaminar);
        for (String dispositivo : dispositivosExaminar) {
            File fDispositivo = buscaDispositivo(dispositivo);
            if (fDispositivo != null) {
                arbolManager.creaArbolDirectorios(tArbol, fDispositivo);
            }
        }
    }

    private File buscaDispositivo(String dispositivo) {
        File fDispositivo = null;
        for (File fRaiz : this.raices) {
            if (fRaiz.getAbsolutePath().equals(dispositivo)) {
                fDispositivo = fRaiz;
            }
        }
        return fDispositivo;
    }

    public static void actualizaInformacion(InformacionArchivo info, Boolean panel) {
        if (panel) {
            actualizaPanel(info);
        }
        Principal.cbEjecutable.setSelected(info.isEjecutable());
        Principal.cbEscribible.setSelected(info.isEscribible());
        Principal.cbLeible.setSelected(info.isLeible());
        Principal.cbOculto.setSelected(info.isOculto());
        Principal.tfNombre.setText(info.getNombre());
        Principal.tfPadre.setText(info.getPadre());
        Principal.tfTamanho.setText(info.getTamanho());
        Principal.tfTamanoDD.setText(info.getTamanhoDisco());
        Principal.tfTamanoUsado.setText(info.getTamanhoUsado());
        Principal.tfTamanoLibre.setText(info.getTamanhoLibre());
        Principal.tfModificacion.setText(info.getUltimaModificacion());
    }

    public static void actualizaPanel(InformacionArchivo info) {
        if (info.getArchivo().isDirectory()) {
            JPanel tmp = null;
            if (tipoVista == VISTA_ARCHIVOS) {
                pDirectorio.actualizaInformacion(archivosUtil.getContenido(info.getArchivo()));
                pDirectorio.setVisible(Boolean.TRUE);
                pDirectorioIconos.setVisible(Boolean.FALSE);
                tmp = pDirectorio;
                pInterno.remove(pDirectorioIconos);
            } else if (tipoVista == VISTA_ICONOS) {
                pDirectorioIconos.actualizaInformacion(archivosUtil.getContenido(info.getArchivo()));
                pDirectorioIconos.setVisible(Boolean.TRUE);
                pDirectorio.setVisible(Boolean.FALSE);
                tmp = pDirectorioIconos;
                pInterno.remove(pDirectorio);
            }
            pInterno.add(tmp);
        } else {
            pInterno.remove(pDirectorio);
            pInterno.remove(pDirectorioIconos);
        }
        pInterno.updateUI();
    }

    public void activaArbol() {
        tArbol.setEnabled(true);
    }
}
